<template>
	<!-- 切换字体库 -->
  <el-dropdown trigger="click" @command="handleSetSize">
    <div>	
		<i class="el-icon-edit-outline"></i>
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item v-for="item of fontFamilyOptions" :key="item.value" :disabled="fontFamily===item.value" :command="item.value">
        {{
          item.label }}
      </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {
  data() {
    return {
      fontFamilyOptions: [
		{ label: '系统字体', value: 'font-family-1' },
        { label: '夏行楷', value: 'font-family-2' },
        { label: '秋鸿楷', value: 'font-family-3' },
        { label: '简中楷', value: 'font-family-4' },
      ]
    }
  },
  computed: {
    fontFamily() {
      return this.$store.getters.fontFamily
    }
  },
  methods: {
    handleSetSize(fontFamily) {
      this.$ELEMENT.fontFamily = fontFamily
      this.$store.dispatch('app/setFontFamily', fontFamily)
      this.$message({
        message: '切换成功',
        type: 'success'
      })
    },
  }

}
</script>
